import 'package:boss/models/takeout_order_list_data.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/takeoutManagement/constant/takeout_status.dart';
import 'package:boss/ui/page/takeoutManagement/page/takeoutDetail/takeout_detail_page.dart';
import 'package:boss/ui/widget/label_button.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

import 'message_row.dart';

class OrderMessage extends StatelessWidget {
  final TakeoutOrderItem data;

  const OrderMessage({Key key, this.data}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        MessageRow(
          children: <Widget>[
            Text('下单时间：${data.ctime}'),
            Text('订单编号：${data.takeOutId}'),
            RichText(
              text: TextSpan(text: '实收金额：', style: TextStyleConstant().normal_2_26, children: [
                TextSpan(
                  text: '¥${AmountUtil.price2String(data.totalAmount)}',
                  style: TextStyleConstant().normal_1_28,
                ),
              ]),
            ),
            if (data.takeOutStatus == TakeoutStatus.ORDER_COMPUTED && data.type == TakeoutStatus.SELF_PICK)
              Text(
                '订单于：${data.pickupTime}客户自取',
                style: TextStyleConstant().normal_1_26,
              ),
          ],
          suffix: LabelButton(
            title: '详细>',
            textStyle: TextStyleConstant().blue_28,
            onTap: () async {
              Navigator.pushNamed(context, TakeoutDetailPage.pageName, arguments: {'takeoutId': data.takeOutId});
            },
          ),
        ),
        if (data.type == TakeoutStatus.SELF_PICK && data.pickupCode != null)
          Positioned(
            bottom: 25.w,
            right: 20.w,
            child: Text(
              '取件码：${data.pickupCode}',
              style: TextStyleConstant().blue_28,
            ),
          ),
      ],
    );
  }
}
